package com.example.pushdeom.Bean;

import android.app.Activity;
import android.os.Bundle;

import com.tencent.connect.share.QQShare;
import com.tencent.connect.share.QzoneShare;
import com.tencent.tauth.Tencent;

import java.util.ArrayList;

public class ShareList {

    //QQ登录
    public static void qqLogin(Tencent mTencent, Activity activity) {
        mTencent.login(activity,"all",new ShareUiListener());
    }

    //QQ 分享
    // 链接分享
    public static void qqShare(Tencent mTencent, Activity activity) {
        final Bundle params = new Bundle();

        params.putInt(QQShare.SHARE_TO_QQ_KEY_TYPE, QQShare.SHARE_TO_QQ_TYPE_DEFAULT);//分享的类型

        params.putString(QQShare.SHARE_TO_QQ_TITLE, "Android记事苟CSDN博客");//分享标题

        params.putString(QQShare.SHARE_TO_QQ_SUMMARY,"这是QQ分享功能，可以点击进去看看");//要分享的内容摘要

        params.putString(QQShare.SHARE_TO_QQ_TARGET_URL,"https://blog.csdn.net/weixin_43638289?spm=1001.2014.3001.5343");//内容地址

        params.putString(QQShare.SHARE_TO_QQ_IMAGE_URL,"https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fup.enterdesk.com%2Fedpic_360_360%2Fbb%2F20%2Fb7%2Fbb20b7375ec16564f09c959fa3d91613.jpg&refer=http%3A%2F%2Fup.enterdesk.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1624785783&t=efa992f79cbcf585d938f7ab585f0245");//分享的图片URL

        params.putString(QQShare.SHARE_TO_QQ_APP_NAME, "测试应用");//应用名称

        mTencent.shareToQQ(activity, params, new ShareUiListener());

    }

    //QQ 空间分享
    // 链接分享
    public static void qqQzoneShare(Tencent mTencent, Activity activity) {
        int QzoneType = QzoneShare.SHARE_TO_QZONE_TYPE_NO_TYPE;

        Bundle params = new Bundle();

        params.putInt(QzoneShare.SHARE_TO_QZONE_KEY_TYPE, QzoneType);

        params.putString(QzoneShare.SHARE_TO_QQ_TITLE, "Android记事苟CSDN博客");//分享标题

        params.putString(QzoneShare.SHARE_TO_QQ_SUMMARY, "不管在实现的过程中是怎样的艰辛，只要达到预期效果，就不算辜负自己的付出");//分享的内容摘要

        params.putString(QzoneShare.SHARE_TO_QQ_TARGET_URL, "https://blog.csdn.net/weixin_43638289?spm=1001.2014.3001.5343");//分享的链接

//分享的图片, 以ArrayList的类型传入，以便支持多张图片(注：图片最多支持9张图片，多余的图片会被丢弃)

        ArrayList imageUrls = new ArrayList();

        imageUrls.add("https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fup.enterdesk.com%2Fedpic_360_360%2Fbb%2F20%2Fb7%2Fbb20b7375ec16564f09c959fa3d91613.jpg&refer=http%3A%2F%2Fup.enterdesk.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1624785783&t=efa992f79cbcf585d938f7ab585f0245");
        params.putStringArrayList(QzoneShare.SHARE_TO_QQ_IMAGE_URL, imageUrls);//分享的图片URL

        mTencent.shareToQzone(activity, params, new ShareUiListener());

    }
}
